home *** CD-ROM | disk | FTP | other *** search
/ The Sunday Times: The Month 2004 August / The Sunday Times - The Month 2004-08.iso / pc / engine / shell / shell.swf / scripts / DefineSprite_108 / frame_1 / DoAction.as
Text File  |  2004-07-06  |  5KB  |  218 lines

  1. function init()
  2. {
  3.    this.createEmptyMovieClip("mc_anim",Tardis.depth++);
  4.    restart();
  5. }
  6. function destroy()
  7. {
  8.    trace("-- kill the splashes");
  9.    removeMovieClip("mc_anim");
  10. }
  11. function clearUp()
  12. {
  13.    Tardis.TardisInterface.setObjProperty("isSplashAnimating",false);
  14.    mc_anim.unloadMovie();
  15.    delete onEnterFrame;
  16.    delete onAnimationEnd;
  17.    delete strLastSection;
  18. }
  19. function restart()
  20. {
  21.    trace("restart()");
  22.    Tardis.TardisInterface.setObjProperty("isSplashAnimating",true);
  23.    Tardis.UsageData.addPageEntry(-1);
  24.    nmCurrent = -1;
  25.    next();
  26.    onAnimationEnd = function()
  27.    {
  28.       next();
  29.    };
  30.    startSoundLoop();
  31. }
  32. function pauseAt(section_name)
  33. {
  34.    if(section_name != strLastSection)
  35.    {
  36.       mc_anim.onLoad = function()
  37.       {
  38.          this.onLoad = null;
  39.          this.pause = true;
  40.       };
  41.       load(section_name);
  42.    }
  43.    else
  44.    {
  45.       mc_anim.pause = true;
  46.       mc_anim.gotoAndStop("still");
  47.    }
  48.    nmCurrent = Tardis.Sections.indexOf(section_name);
  49. }
  50. function playFrom(section_name)
  51. {
  52.    nmCurrent = -1;
  53.    mc_anim.onLoad = function()
  54.    {
  55.       this.onLoad = null;
  56.       this.entering = true;
  57.    };
  58.    load(section_name);
  59. }
  60. function playStart(section_name)
  61. {
  62.    mc_anim.onLoad = function()
  63.    {
  64.       this._parent.playStartWhenLoaded();
  65.       this.onLoad = null;
  66.    };
  67.    load(section_name);
  68. }
  69. function resume()
  70. {
  71.    Tardis.TardisInterface.setObjProperty("isSplashAnimating",true);
  72.    this._visible = true;
  73.    mc_anim.play();
  74.    mc_anim.pause = false;
  75. }
  76. function restartSection()
  77. {
  78.    mc_anim.gotoAndPlay("start");
  79. }
  80. function interrupt()
  81. {
  82.    mc_anim.stop();
  83. }
  84. function hide()
  85. {
  86.    interrupt();
  87.    this._visible = false;
  88. }
  89. function show()
  90. {
  91.    Tardis.TardisInterface.setObjProperty("isSplashAnimating",true);
  92.    mc_anim.play();
  93.    this._visible = true;
  94. }
  95. function load(section_name)
  96. {
  97.    mc_anim.loadMovie(Tardis.ASSETS_FOLDER + "splash/" + section_name + ".swf");
  98.    strLastSection = section_name;
  99. }
  100. function next()
  101. {
  102.    Tardis.bottomNav.splashOff(Tardis.Sections.item(nmCurrent).id);
  103.    nmCurrent++;
  104.    if(nmCurrent >= Tardis.Sections.length)
  105.    {
  106.       nmCurrent = 0;
  107.    }
  108.    var section_name = Tardis.Sections.item(nmCurrent).id;
  109.    if(section_name == null)
  110.    {
  111.       trace("splash : can\'t find index in Sections");
  112.    }
  113.    else
  114.    {
  115.       mc_anim.onLoad = function()
  116.       {
  117.          this._parent.playStartWhenLoaded();
  118.          this.onLoad = null;
  119.       };
  120.       load(section_name);
  121.       Tardis.bottomNav.splashOn(Tardis.Sections.item(nmCurrent).id);
  122.    }
  123. }
  124. function playStartWhenLoaded()
  125. {
  126.    mc_anim.onEnterFrame = function()
  127.    {
  128.       if(this.getBytesLoaded() == this.getBytesTotal())
  129.       {
  130.          this.gotoAndPlay("start");
  131.          this.onEnterFrame = null;
  132.       }
  133.    };
  134. }
  135. function __onAnimationEnd()
  136. {
  137.    onAnimationEnd();
  138. }
  139. function startSoundLoop()
  140. {
  141.    trace("startSoundLoop()");
  142.    if(!Tardis.mc_snd_splash_loop)
  143.    {
  144.       Tardis.createEmptyMovieClip("mc_snd_splash_loop",-10);
  145.       Tardis.mc_snd_splash_loop.loadMovie(Tardis.ENGINE_FOLDER + "swf/bg_sound.swf");
  146.    }
  147.    else
  148.    {
  149.       fadeSoundLoop();
  150.    }
  151.    fadeSoundID = setInterval(monitorSoundLoop,40);
  152. }
  153. function monitorSoundLoop()
  154. {
  155.    mcSnd = Tardis.mc_snd_splash_loop;
  156.    if(mcSnd.getBytesLoaded() >= mcSnd.getBytesTotal() && mcSnd.getBytesTotal() > 4)
  157.    {
  158.       clearInterval(fadeSoundID);
  159.       fadeSoundLoop();
  160.    }
  161. }
  162. function fadeSoundLoop()
  163. {
  164.    trace("fadeSoundLoop()");
  165.    trace("mcSnd: " + mcSnd);
  166.    trace("ncSnd.active: " + mcSnd.active);
  167.    if(mcSnd.active == true)
  168.    {
  169.       return undefined;
  170.    }
  171.    var sndLoop = mcSnd.snd = new Sound(mcSnd);
  172.    sndLoop.v = 0;
  173.    sndLoop.setVolume(0);
  174.    mcSnd.gotoAndStop("show");
  175.    mcSnd.active = true;
  176.    mcSnd.onEnterFrame = function()
  177.    {
  178.       with(this)
  179.       {
  180.          snd.v += 4;
  181.          if(snd.v <= 100)
  182.          {
  183.             snd.setVolume(snd.v);
  184.          }
  185.          else
  186.          {
  187.             onEnterFrame = null;
  188.          }
  189.       }
  190.    };
  191. }
  192. function endSoundLoop()
  193. {
  194.    if(mcSnd.active != true)
  195.    {
  196.       return undefined;
  197.    }
  198.    mcSnd.onEnterFrame = function()
  199.    {
  200.       with(this)
  201.       {
  202.          snd.v -= 8;
  203.          if(snd.v >= 0)
  204.          {
  205.             snd.setVolume(snd.v);
  206.          }
  207.          else
  208.          {
  209.             snd.stop();
  210.             delete snd;
  211.             gotoAndStop("hide");
  212.             active = false;
  213.             onEnterFrame = null;
  214.          }
  215.       }
  216.    };
  217. }
  218.